//获取应用实例
var app = getApp()
Page({
  data: {
    userInfo: {},
    userId:''
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
  },
  toMyMark:function(){
    wx.navigateTo({
      url: '../mycontent/index?tag=mark'
    })
  },
  toMyLike:function(){
    wx.navigateTo({
      url: '../mycontent/index?tag=like'
    })
  },
  toAbout:function(){
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  //获取openid
  getOpenID:function(){
    var that = this;
    wx.login({
      success: (res)=>{
       // console.log(res.code);
        wx.request({
           url:'https://api.weixin.qq.com/sns/jscode2session?appid=wxf89f318b1e769832&secret=38f45a85816ef2f9508f9b2c58adfa81&js_code='+res.code+'&grant_type=authorization_code',
           success:function(data){
              //console.log(data.data.openid)
              that.setData({
                  userId:data.data.openid
              });
           }
         })
      },
    })
  }
})
